package org.nanotek.cms.domain.lucene;

import java.util.Date;
import java.util.Set;

import org.nanotek.StringKong;
import org.nanotek.cms.domain.MediaDetail;
import org.nanotek.lucene.index.search.AnalyzerType;
import org.nanotek.lucene.index.search.IndexType;
import org.nanotek.util.Base;

import com.sun.syndication.feed.atom.Link;

@SuppressWarnings("serial")
public class Index extends StringKong implements Base<String> {

	private Link location;
	private String indexAlias;
	private IndexType indexType;
	private AnalyzerType analyzerType;
	private Date dateCreated;
	private Date dateUpdated;
	private String indexState;
	private IndexDescription indexDescription;

	private Set<MediaDetail> documents;

	public Index() {
		super(Long.toString(System.currentTimeMillis()));
	}

	public String getIndexAlias() {
		return indexAlias;
	}

	public void setIndexAlias(String indexAlias) {
		this.indexAlias = indexAlias;
	}

	public IndexType getIndexType() {
		return indexType;
	}

	public void setIndexType(IndexType indexType) {
		this.indexType = indexType;
	}

	public void setLocation(Link location) {
		this.location = location;
	}

	public Link getLocation() {
		return location;
	}

	public Set<MediaDetail> getDocuments() {
		return documents;
	}

	public void setDocuments(Set<MediaDetail> documents) {
		this.documents = documents;
	}

	public AnalyzerType getAnalyzerType() {
		return this.analyzerType;
	}

	public void setAnalyzerType(AnalyzerType analyzerType) {
		this.analyzerType = analyzerType;
	}

	public Date getDateCreated() {
		return dateCreated;
	}

	public void setDateCreated(Date dateCreated) {
		this.dateCreated = dateCreated;
	}

	public Date getDateUpdated() {
		return dateUpdated;
	}

	public void setDateUpdated(Date dateUpdated) {
		this.dateUpdated = dateUpdated;
	}

	public String getIndexState() {
		return indexState;
	}

	public void setIndexState(String indexState) {
		this.indexState = indexState;
	}


	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((analyzerType == null) ? 0 : analyzerType.hashCode());
		result = prime * result
				+ ((documents == null) ? 0 : documents.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result
				+ ((indexAlias == null) ? 0 : indexAlias.hashCode());
		result = prime * result
				+ ((indexType == null) ? 0 : indexType.hashCode());
		result = prime * result
				+ ((location == null) ? 0 : location.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Index other = (Index) obj;
		if (analyzerType != other.analyzerType)
			return false;
		if (documents == null) {
			if (other.documents != null)
				return false;
		} else if (!documents.equals(other.documents))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (indexAlias == null) {
			if (other.indexAlias != null)
				return false;
		} else if (!indexAlias.equals(other.indexAlias))
			return false;
		if (indexType != other.indexType)
			return false;
		if (location == null) {
			if (other.location != null)
				return false;
		} else if (!location.equals(other.location))
			return false;
		return true;
	}

	public IndexDescription getIndexDescription() {
		return indexDescription;
	}

	public void setIndexDescription(IndexDescription indexDescription) {
		this.indexDescription = indexDescription;
	}

}
